/**
 * Created by zhuyufeng on 2016/1/2.
 */
Ext.define('homeModel', {
	extend: 'Ext.data.Model',
	fields: [ 'id', 'person1','person2','person3','person4']
});
var homeStore = Ext.create('Ext.data.Store', {
	model: 'homeModel',
	autoLoad: true,
	pageSize: 10,
	proxy: {
		type: 'ajax',
		url : './json/home',
		reader: {
			type: 'json',
			root: 'rows',
			totalProperty: 'total'
		}
	}
});

var homegrid = Ext.create('Ext.grid.Panel', {
	store: homeStore,
	homeName:null,
	columns: [
		{text: '寝室号',width: 100,dataIndex: 'id'},
		{text: '成员1',width: 150,dataIndex: 'person1'},
		{text: '成员2',width: 150,dataIndex: 'person2'},
		{text: '成员3',width: 150,dataIndex: 'person3'},
		{text: '成员4',width: 150,dataIndex: 'person4'}
	],
	dockedItems:[{
		xtype:'pagingtoolbar',
		store:homeStore,
		dock:'bottom',
		displayInfo:true,
		displayMsg:'第{0}条到第{1}条,一共{2}条',
		emptyMsg:'没有记录'
	}],
	listeners:{
		itemclick:function(grid,rcd){
			var a = rcd.raw.id;
			var syswin = Ext.create('Ext.window.Window', {
				title:a,
				width: 750,
				modal: 'true',
				bodyStyle: "padding:0 0 0 0",
				items: [personGrid],
				closeAction:'close'
			})
			syswin.show();
		}
	}
});

var msgs = new Ext.Panel({
	title:'信息管理',
	items:[homegrid]
})